import proFetch from "../../../../../../public/functions/project-fetch";
import {toast} from 'nc-lightapp-front'

export default function saveBlacklistData() {
    const {orgVal, table} = this.props;
    if (!this.state.addReason) {
        toast({color: "danger", content: this.props.json['hi6007-000194']});
        return;
    }
    const checkedRows = table.getCheckedRows('info');
    const selectedPsn = checkedRows.map(row=>row.data.values.pk_psnjob.value).join()

    let postData = {
        addReason: this.state.addReason,
        pk_psnjob: selectedPsn,
        pk_org: orgVal.refpk
    };

    return proFetch({
        url: '/nccloud/hrtrn/dimissionrds/DimissionRdsAddBlackListDoAction.do',
        body: postData,
    })
        .then((res) => {
            if (res.success) {
                toast({
                    color: 'success',
                    content: this.props.json['hi6007-000132']/* 国际化处理： 加入黑名单成功*/
                });
                this.closeModal();
            }
        });
}
